package com.vinoxm.rss.dao;

import com.vinoxm.rss.model.RssResult;
import com.vinoxm.rss.vo.RssResultVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RssResultDao {

    @Select("SELECT id, pid, title, torrent, pub_date pubDate, hide, tracker, episode FROM rss_result")
    List<RssResultVo> selAll();

    @Select("SELECT id, pid, title, torrent, pub_date pubDate, hide, tracker, episode FROM rss_result WHERE episode='-'")
    List<RssResultVo> selAllWithoutEpisode();

    @Delete("DELETE FROM rss_result")
    void delAll();

    @Insert("<script>" +
            "INSERT INTO rss_result" +
            "(id,pid, title, torrent, pub_date, hide, tracker) " +
            "VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.id}, #{item.pid}, #{item.title}, #{item.torrent}, #{item.pubDate}, #{item.hide}, #{item.tracker})" +
            "</foreach>" +
            "</script>")
    int insertAll(List<RssResultVo> list);
}
